//package cn.bitoffer.lottery.kafka.consumer;
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.kafka.clients.consumer.ConsumerRecord;
//import org.springframework.kafka.annotation.KafkaListener;
//import org.springframework.kafka.support.Acknowledgment;
//import org.springframework.kafka.support.KafkaHeaders;
//import org.springframework.messaging.handler.annotation.Header;
//import org.springframework.stereotype.Component;
//
//import java.util.Optional;
//
//@Component
//@Slf4j
////public class HelloWorldConsumer {
////    @KafkaListener(topics = "hello-world", groupId = "TEST_GROUP",concurrency = "1", containerFactory = "kafkaManualAckListenerContainerFactory")
////    public void topic_test(ConsumerRecord<?, ?> record, Acknowledgment ack, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) {
////        Optional message = Optional.ofNullable(record.value());
////        if (message.isPresent()) {
////            Object msg = message.get();
////            try {
////                // 这里写你对接收到的消息的处理逻辑
////                // 手动ACK
////                ack.acknowledge();
////                log.info("Kafka消费成功! Topic:" + topic + ",Message:" + msg);
////            } catch (Exception e) {
////                e.printStackTrace();
////                log.error("Kafka消费失败！Topic:" + topic + ",Message:" + msg, e);
////            }
////        }
////    }
////
////}




